package cn.gjxblog.modules.sys.controller;

import cn.gjxblog.common.model.HttpResult;
import cn.gjxblog.common.model.PageInfo;
import cn.gjxblog.common.model.PageRequest;
import cn.gjxblog.modules.sys.entity.SysLogEntity;
import cn.gjxblog.modules.sys.service.SysLogService;
import cn.gjxblog.modules.third.oss.OssServiceContext;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 系统日志
 *
 * @author guojiaxun
 * @date 2019-09-12 10:27:45
 */
@RestController
@RequestMapping("sys/syslog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @Autowired
    private OssServiceContext ossServiceContext;
    /**
     * 列表
     */
    @PostMapping("/searchList")
    @ApiOperation("获取列表")
    public HttpResult<PageInfo> searchList(@RequestBody PageRequest pageRequest){
        PageInfo pageInfo = sysLogService.searchList(pageRequest);
        return HttpResult.ok(pageInfo);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation("获取信息")
    public HttpResult<SysLogEntity> info(@PathVariable("id") Long id){
		SysLogEntity sysLog = sysLogService.getById(id);
        return HttpResult.ok(sysLog);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("保存信息")
    public HttpResult save(@RequestBody SysLogEntity sysLog){
		sysLogService.save(sysLog);
        return HttpResult.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改信息")
    public HttpResult update(@RequestBody SysLogEntity sysLog){
		sysLogService.updateById(sysLog);
        return HttpResult.ok();
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    @ApiOperation("删除信息")
    public HttpResult delete(String id){
		sysLogService.removeById(id);
        return HttpResult.ok();
    }

}
